import celery
import time

# BROKER_URL='redis://:xxxxx@127.0.0.1:6379/2'
backend = 'redis://:zzt123@111.229.249.204/1'
broker = 'redis://:zzt123@111.229.249.204/2'
cel = celery.Celery('test', backend=backend, broker=broker)


@cel.task
def send_email(name):
    print("向%s发送邮件..." % name)
    time.sleep(5)
    print("向%s发送邮件完成" % name)
    return "ok"


@cel.task  # 申明任务
def send_msg(name):
    print("向%s发送信息..." % name)
    time.sleep(5)
    print("向%s发送信息完成" % name)
    return "ok"

# 消费者，创建监听任务，执行任务逻辑
